buildroot构建项目(二) |
您所在的位置:网站首页 › uboot menuconfig boot media › buildroot构建项目(二) |
一、准备工作
在建立之前,先需要将下载的u-boot 拷贝一份出来解压,在此工程下进行更改和创建。同时根据前面搜索到的 mini2440开发板所在的版本,下载一份u-boot 拷贝出 mini2440 的工程文件。 选择2013.10版本的 u-boot。下载,并解压。 1.1 board 目录修改u-boot-2013.10/board/samsung/smdk2410 复制进 u-boot-2017.11/board/samsung/ 目录 文件名修改:
Makefile 修改为:
创建 Kconfig 文件并修改: 1.2 头文件修改 u-boot-2013.10/include/configs/smdk2410.h 拷贝进 u-boot-2017.11//include/configs/mini2440.h
在头文件中添加对 S3C2440芯片的支持:
在2013.10版本中,执行命令:grep -R -l "smdk2410.h" 查找是否还有包含 smdk2410.h 文件 1.3 修改arch/arm下文件 1.3.1 修改Kconfig文件当前新版的u-boot与linux源码一样,都执行make menuconfig 进行配置,所以在configs目录下要有mini2440的配置
1.3.2 修改arch/arm/include/asm/mach-types.h mach-types.h 已经有了相关配置:
1.3.3 加入S3C24X0文件夹 u-boot-2013.10/arch/arm/cpu/arm920t/s3c24x0 复制进 u-boot-2017.11/arch/arm/cpu/arm920t/目录 1.4 修改 u-boot-2017.11/configs 下的defconfig文件在新版本的 u-boot 中,并没有我们适用和仿照的配置文件。既然没有,那么我们执行 make menuconfig 在其中配置一份最小配置。 Architecture select:架构,选择 ARM architecture ARM architecture: Target select:选择我们配置的开发板 mini2440 其余全不选中 General setup:通用配置 选中 Configure standard U-boot features 即可,其余全不选。 boot images 启动镜像,暂且默认 API:默认不选中即可 Boot timing:暂时默认 Boot media:选中支持 NAND flash delay in seconds before automatically booting :启动延迟的时间,设置为5 Enable boot arguments:使能启动命令参数,暂时不做修改,为空 Console:默认 Default fdt file:默认不填 add U-Boot environment variable vers:默认不写 Display information about the CPU during start up:选上 Display information about the board during start up:选上 Start-up hooks:里面是特殊板子的启动选项,默认不选 Security support:编译的选项,暂时默认 SPL / TPL:默认 Command line interface:命令行接口, Support U-Boot commands:支持U-boot命令,选中 Use hush shell:不选 Shell prompt:命令行的类型,默认就好 Autoboot options:自动启动选项,默认即可 Info commands:命令信息,默认即可 Boot commands:启动命令,暂时默认,后面可能裁剪一下 Environment commands:环境变量命令,默认 Memory commands :内存命令 Compression commands:压缩命令 Device access commands:设备到达命令,去掉 fpga,我们是ARM,加入nand命令,其他保持默认 Shell scripting commands:SHELL脚本命令,默认 Network commands:网络命令,暂且默认 Misc commands:杂项命令,都去掉 Power commands:电源命令,无 Security commands:加密命令,不选 Firmware commands:防火墙命令 Filesystem commands:文件系统命令,默认不选 Debug commands:调试命令,默认不选 Enable UBI - Unsorted block images commands:镜像分块命令,默认不选 Partition Types:磁盘类型,暂时默认 Device Tree Control:设备树控制,默认都不选中即可 Path to dtc binary for use within mkimage:dtc二进制文件路径,默认即可 Environment:环境变量,默认即可 Networking support:网络设备支持,默认即可 Device Drivers:设备驱动,暂且默认 File systems:文件系统支持,选择YAFFS2 filesystem support Library routines:库选择,默认即可 Unit tests:单元测试,不选中配置完后,保存编译一遍。 1.5 编译报错解决 1.5.1 config_cmd_default.h: No such file or directory没有 config_cmd_default.h 文件,此文件中装载的是 U-BOOT中的一些命令。 注释掉头文件 1.5.2 lib/asm-offsets.c:1:0: error: bad value (armv4t) for -march= switch一般是由于交叉编译工具链没有指定,在顶层的 Makefile 下加入交叉编译工具链。 1.5.3 重复定义的选项:include/configs/mini2440.h:84:0: warning: "CONFIG_CMD_ELF" redefined include/configs/mini2440.h:85:0: warning: "CONFIG_CMD_NAND" redefined include/configs/mini2440.h:113:0: warning: "CONFIG_SYS_PROMPT" redefined include/configs/mini2440.h:121:0: warning: "CONFIG_DISPLAY_CPUINFO" redefined include/configs/mini2440.h:195:0: warning: "CONFIG_YAFFS2" redefined 这些选项在 config文件或者是 其他文件中都已经定义,先注释掉 1.5.4 scripts/Makefile.build:280: recipe for target 'cmd/reginfo.o' failed cmd/reginfo.c:10:21: fatal error: asm/ppc.h: No such file or directory #include缺少文件。 追踪 reginfo.c 的源码
追踪到 asm/ppc.h 文件 需要宏控制,查找一下此宏在哪里定义的
注释掉: 1.5.5 cmd/ubi.c:79:44: error: ‘CONFIG_MTD_UBI_WL_THRESHOLD’ undeclared (first use in this function)
文件系统全部干掉,menuconfig中可配 1.5.6 drivers/rtc/s3c24x0_rtc.c:17:34: fatal error: asm/arch/s3c24x0_cpu.h: No such file or directory #include头文件未包含。 将文件同步过来即可 保存一下 .config 文件备份,然后 make distclean。再重新编译一遍。 1.5.7 common/built-in.o:(.rodata.init_sequence_f+0x20): undefined reference to `board_early_init_f'common/built-in.o:(.rodata.init_sequence_f+0x4c): undefined reference to `dram_init' common/built-in.o:(.data.init_sequence_r+0x24): undefined reference to `board_init' 查找函数,可以知道 这些函数在 board/samsung/mini2440/mini2440.c 文件中,查看编译的过程 mini2440.c文件并没有编译 修改里面的 board/samsung/mini2440/Makefile 文件为: obj-y = xxx.o:是最基本的赋值,make会将整个makefile展开后,再决定变量的值。也就是说,变量的值将会是整个makefile中最后被指定的值。 obj-y := xxx.o:是覆盖之前的值,表示变量的值决定于它在makefile中的位置,而不是整个makefile展开后的最终值。 obj-y ?= xxx.o:是如果没有被赋值过就赋予等号后面的值 obj-y += xxx.o:是添加等号后面的值 在生成built-in.o的时候,如果使用:使 obj 的值为 lowlevel_init.o,覆盖了mini2440.c。 重新编译:board/samsung/mini2440/mini2440.c: In function ‘board_init’: board/samsung/mini2440/mini2440.c:100:27: error: ‘MACH_TYPE_SMDK2410’ undeclared (first use in this function) gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
再重新编译,依然报错,找到原因是因为我们的 machine_arch_type 没有定义 再 arch/arm/include/asm/mach-types.h 中进行定义,加入如下配置:
文件头上加上:
在board/samsung/mini2440/mini2440.c中加入头文件:
编译,错误终结。 1.5.8 drivers/serial/built-in.o: In function `get_current': 和 drivers/serial/built-in.o: In function `serial_initialize':/u-boot-2017.11/drivers/serial/serial.c:379: undefined reference to `default_serial_console' /u-boot-2017.11/drivers/serial/serial.c:242: undefined reference to `default_serial_console' 查找当前版本和以前的版本进行对比: 当前版本:
以前的版本:
少一个文件: serial_s3c24x0.c,拷贝一份进去 cp ../../uboot/u-boot-2016.01/drivers/serial/serial_s3c24x0.c drivers/serial/serial_s3c24x0.c 修改 Makefile:
执行编译,错误消除。 1.5.9 env/built-in.o: In function `env_flash_save':/u-boot-2017.11/env/flash.c:268: undefined reference to `flash_sect_protect' /u-boot-2017.11/env/flash.c:303: undefined reference to `flash_sect_protect' /env/flash.c:276: undefined reference to `flash_sect_erase' /flash.c:280: undefined reference to `flash_write' /env/flash.c:298: undefined reference to `flash_perror' flash_sect_protect ,flash_sect_erase依赖于宏 CONFIG_MTD_NOR_FLASH 生效
menuconfig 中修改: device drivers > mtd support:选中 norflash support 编译执行,错误消失 1.5.9 Error: You must add new CONFIG options using KconfigThe following new ad-hoc CONFIG options were detected: CONFIG_ARM920T CONFIG_MINI2440 CONFIG_NAND_S3C2440 CONFIG_RTC_S3C24X0 CONFIG_S3C2440 CONFIG_S3C24X0 CONFIG_S3C24X0_SERIAL CONFIG_SYS_HUSH_PARSER CONFIG_SYS_S3C2440_NAND_HWECC CONFIG_ZERO_BOOTDELAY_CHECK Please add these via Kconfig instead. Find a suitable Kconfig file and add a 'config' or 'menuconfig' option. 注释掉顶层 Makefile 中下面几句:
clean 之后编译。 编译完成,生成了 u-boot.bin.
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |